/*左边展开和收起*/
function leftClose(){
  document.getElementById("right").className="right_off";
  document.getElementById("left").style.display="none";
  document.getElementById("close").style.display="none";
  document.getElementById("open").style.display="";
}
function leftOpen(){
  document.getElementById("right").className="right_on";
  document.getElementById("left").style.display="";
  document.getElementById("close").style.display="";
  document.getElementById("open").style.display="none";
}
/*下拉菜单*/
$(document).ready(function(){
	//三级菜单
	$("._lr_systembox_").each(
		function(i){
			var lr_menu = $(this).find("#lr_menu");
			$(this).mouseenter(function(){
					t_delay= setTimeout(function(){
					$(lr_menu).fadeIn("slow");
				},200);
			});
			$(this).mouseleave(function(){
				clearTimeout(t_delay);
				$(lr_menu).fadeOut("slow");
			});
			
		}
	);

});


/*头部和右边TAB*/
function setTab(m,n){
var tli=document.getElementById("menu"+m).getElementsByTagName("li");
for(i=0;i<tli.length;i++){
   tli[i].className=i==n?"hover":"";

}

for(i=0; j=document.getElementById("right_menu"+i); i++){
		j.style.display = "none";
	}
	document.getElementById("right_menu"+n).style.display = "";

}

function setTabLink(n){
	for(i=0; j=document.getElementById("menu_link"+i); i++){
		j.style.color = "#666666";
	}
	document.getElementById("menu_link"+n).style.color = "#0fb3f0";
}

function setTab1(m,n){
var tli=document.getElementById("sale_title"+m).getElementsByTagName("li");
//var mli=document.getElementById("sale_content"+m).getElementsByClassName("sale");
for(i=0;i<tli.length;i++){
   tli[i].className=i==n?"hover":"";
   //mli[i].style.display=i==n?"block":"none";
}

for(i=0; j=document.getElementById("tagSale"+i); i++){
		j.style.display = "none";
	}
	document.getElementById("tagSale"+n).style.display = "";

}
/*左边TAB*/
function setTab2(m,n){
var tli=document.getElementById("left_title"+m).getElementsByTagName("li");
//var mli=document.getElementById("left_content"+m).getElementsByClassName("left_tab");
for(i=0;i<tli.length;i++){
   tli[i].className=i==n?"hover":"";
 //  mli[i].style.display=i==n?"block":"none";
}

for(i=0; j=document.getElementById("left_tab"+i); i++){
		j.style.display = "none";
	}
	document.getElementById("left_tab"+n).style.display = "";
}

 function SetCwinHeight(obj){
try{
	  var iframeid=document.getElementById("admin_main_frame"); //iframe id
	  
	  if (document.getElementById){
	
	   if (iframeid && !window.opera){
	
	    if (iframeid.contentDocument && iframeid.contentDocument.body.offsetHeight){
	      //iframeid.height = iframeid.contentDocument.body.offsetHeight;
	      var myheight = iframeid.contentDocument.body.offsetHeight;
		  if(myheight<480){
			 iframeid.height=480;
		   }else {
			 iframeid.height= myheight;
			}
	    }else if(iframeid.Document && iframeid.Document.body.scrollHeight){
	    	var myheight = iframeid.Document.body.scrollHeight;
			if(myheight<480){
				 iframeid.height=480;
		  	 }else {
				 iframeid.height= myheight;
			}
			
	    }
	
	   }
	
	  }
	  setReadonlyNoFocus();
 
	}catch(e){}  

 }
  // 根据主交易区的大小调整显示效果
function sizeChange() {
	try {
		window.setInterval('SetCwinHeight(2)', 200);
	} catch (e) {}
}
  
  /**快捷功能 */
  function quickMenuClick(id){
  	$("#left_load_more").hide();
 	if(id==0){
   		
   	}
	if(id==1){
		  var url="${ctx }/default_applicationInfo.do?f=1";
		  var postData = "";
		  var zones = "application_zone,application_zone_count";
		  ajaxAnywhere.submitAJAXByUrl(url,postData,zones);
		   $("#left_load_more").show();
		   
	}
	if(id==2){
	 	var url="${ctx }/default_notifiInfo.do?f=1";
		var postData = "";
		var zones = "notifi_zone,notifi_zone_count";
		ajaxAnywhere.submitAJAXByUrl(url,postData,zones);
	}
 	$("#left_title0").attr("compact",id);
 	
  }
  //更新数量
  function quickMenuClickNum(){
      var url="${ctx }/default_countStaticInfo.do?f=1";
	  var postData = "";
	  var zones = "approve_zone_count,notifi_zone_count,application_zone_count";
	  ajaxAnywhere.submitAJAXByUrl(url,postData,zones);
  }
  /**点击父菜单 */
  function parentMenuClick(id){
  	$("#right_menu"+id).find("a[name='meun_link_a']").each(
  		function(i){
  			if(i==0){
  				$(this).click();
  			}
  		}
  	);
  }
  
  	/**
 	 * 只能输入数字
 	 */
function onlyNumber(obj) {
	obj.value = obj.value.replace(/[^\d\.]+/g, '');
}
function checkDate(sid, eid){
	var startDate = document.getElementById(sid).value;
	var endDate = document.getElementById(eid).value;
	if(startDate != null && startDate != "" && endDate != null && endDate != ""){
		if(startDate > endDate){
			alert("开始时间不能大于结束时间!");
			return false;
		}
	}
	return true;
}
  
  
function isUndefined(tmp) {
	if (typeof (tmp) == "undefined") {
		return true;
	} else {
		return false;
	}
}

function isEmpty(tmp) {
	if ($.trim(tmp) == "") {
		return true;
	} else {
		return false;
	}
}
function isNull(arg1){
 return !arg1 && arg1!==0 && typeof arg1!=="boolean"?true:false;
}

function isCanNotAccess(tmp) {
	if (isUndefined(tmp) || isEmpty(tmp) || isNull(tmp)) {
		return true;
	} else {
		return false;
	}
}

function formatDateToStr(time) {
	var datetime = new Date();
	datetime.setTime(time);
	var year = datetime.getFullYear();
	var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1)
			: datetime.getMonth() + 1;
	var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime
			.getDate();
	var hour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime
			.getHours();
	var minute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes()
			: datetime.getMinutes();
	var second = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds()
			: datetime.getSeconds();
	return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":"
			+ second;
}

function getDateMonthFirstDateStr(time) {
	var datetime = new Date();
	datetime.setTime(time);
	var year = datetime.getFullYear();
	var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1)
			: datetime.getMonth() + 1;
	var date = "01";
	return year + "-" + month + "-" + date;

}
function getDateMonthLastDateStr(time) {
	var datetime = new Date();
	datetime.setTime(time);
	var year = datetime.getFullYear();
	var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1)
			: datetime.getMonth() + 1;
	
	var day = new Date(year,month,0);      
	return year + "-" + month + "-" + day.getDate();

}
function addMonth(theTime, num) {
    num = parseInt(num,"10");
	var datetime = new Date();
	datetime.setTime(theTime);
	var sYear = datetime.getFullYear();
    var sMonth = datetime.getMonth() + 1;
    var sDay = datetime.getDate();

    var eYear = sYear;
    var eMonth = sMonth + num;
    var eDay = sDay;
    while (eMonth > 12) {
      eYear++;
      eMonth -= 12;
    }
    var eDate = new Date(eYear, eMonth - 1, eDay);
    while (eDate.getMonth() != eMonth - 1) {
      eDay--;
      eDate = new Date(eYear, eMonth - 1, eDay);
    }
    return eDate;
}

function addDayTimes(theTime, num) {
    num = parseInt(num,"10");
    return theTime+24*60*60*1000*num;
}

function getDateWeekMondayStr(time) {
	var datetime = new Date();
	datetime.setTime(time);
	var day=datetime.getDay();
	var oneDayLong = 24*60*60*1000 ; 
	var mondayTime = time - (day-1)*oneDayLong;
	
	return formatDateToStrOnlyDay(mondayTime);

}
function getDateWeekSundayStr(time) {
	var datetime = new Date();
	datetime.setTime(time);
	var day=datetime.getDay();
	var oneDayLong = 24*60*60*1000 ; 
	var sundayTime  = time + (7-day)*oneDayLong ; 
   
	return formatDateToStrOnlyDay(sundayTime);

}


function formatDateToStrOnlyDay(time) {
	var datetime = new Date();
	datetime.setTime(time);
	var year = datetime.getFullYear();
	var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1)
			: datetime.getMonth() + 1;
	var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime
			.getDate();
	var hour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime
			.getHours();
	var minute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes()
			: datetime.getMinutes();
	var second = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds()
			: datetime.getSeconds();
	return year + "-" + month + "-" + date;
}

function getDateTimeFromStr(str) {
	var theStrDate = str.split(" ")[0];
	var theStrTime = str.split(" ")[1];

	var year = theStrDate.split("-")[0];
	var month = theStrDate.split("-")[1];
	var day = theStrDate.split("-")[2];
	var hour = theStrTime.split(":")[0];
	var minute = theStrTime.split(":")[1];
	var second = theStrTime.split(":")[2];

	var datetime = new Date();
	datetime.setFullYear(year);
	datetime.setMonth(month - 1);
	datetime.setDate(day);
	datetime.setHours(hour);
	datetime.setMinutes(minute);
	datetime.setSeconds(second);
	return datetime.getTime();
}

function getDateTimeFromYYYYMMDDStr(str) {
	var year = str.split("-")[0];
	var month = str.split("-")[1];
	var day = str.split("-")[2];
	var datetime = new Date();
	datetime.setFullYear(year);
	datetime.setMonth(month - 1);
	datetime.setDate(day);
	datetime.setHours(0);
	datetime.setMinutes(0);
	datetime.setSeconds(0);
	return datetime.getTime();
}

function formatDateToStrWithoutSecend(time) {
	var datetime = new Date();
	datetime.setTime(time);
	var year = datetime.getFullYear();
	var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1)
			: datetime.getMonth() + 1;
	var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime
			.getDate();
	var hour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime
			.getHours();
	var minute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes()
			: datetime.getMinutes();
	var second = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds()
			: datetime.getSeconds();
	return year + "-" + month + "-" + date + " " + hour + ":" + minute;
}

function formatDateToStrNoYear(time) {
	var datetime = new Date();
	datetime.setTime(time);
	var year = datetime.getFullYear();
	var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1)
			: datetime.getMonth() + 1;
	var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime
			.getDate();
	var hour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime
			.getHours();
	var minute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes()
			: datetime.getMinutes();
	var second = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds()
			: datetime.getSeconds();
	return month + "-" + date + " " + hour + ":" + minute;
}

function formatDateToHourMinute(time){
	var datetime = new Date();
	datetime.setTime(time);
	var hour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime
			.getHours();
	var minute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes()
			: datetime.getMinutes();
	return "" + hour + ":" + minute;	
}  
  
function isNotBlank(theVal){
	if($.trim(theVal)!=""){
		return true;
	}else{
		return false;
	}
}

function convertUrlParamStrToJSON(paramStr){
	var paramItems=new Array();
	if(isNotBlank(paramStr)&&paramStr.indexOf("?")==0){
		paramItems=paramStr.substring(1,paramStr.length).split('&');
	}else{
		paramItems=paramStr.split('&');
	}
	var resultJson = {};
	for(var i = 0;i<paramItems.length;i++){
	    var oneItemStr = paramItems[i].split('=');
	    resultJson[oneItemStr[0]]=oneItemStr[1];
	}
	return resultJson;
}

function httpEncodeSpecialChar(sStr) { 
	return escape(sStr).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27').replace(/\//g,'%2F');
}


